﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Manager_System
{
    public partial class WH_add_product : Form
    {
        main_form form1;
        public WH_add_product(main_form form)
        {
            form1 = form;
            InitializeComponent();
        }

        private void add_product_bt_Click(object sender, EventArgs e)
        {
            string sql = "";

            sql = "insert into T_WH_product (Type,Material,Specification,Weight,Price) values ('" + species_tb.Text + "','" + material_cb.SelectedItem.ToString() + "','" + specification_tb.Text + "','"+weight_tb.Text+"',"+price_tb.Text+")";

            DBhelp db = new DBhelp();
            int rs = db.update(sql);
            if (rs == 1)
            {
                MessageBox.Show("添加成功！");
                
            }
            else
            {
                MessageBox.Show("添加失败！");

            }
            db.close();
            form1.Refresh_warehouse_product_LV();
        }

        private void WH_add_product_Load(object sender, EventArgs e)
        {
            if (this.material_cb.Items.Count == 0)
            {
             
                string sql = "select NAME from T_material";
                DBhelp db = new DBhelp();
                SqlDataReader reader = db.query(sql);
                while (reader.Read())
                {

                    material_cb.Items.Add(reader["NAME"].ToString());
                    
                }
                db.close();
            }
        }

        private void close_tb_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
